import type { IDirectPurchaseOrderRemark } from "@/types/rentMachineManage/directPurchaseOrderInfo";
import type { IRentMachineOrderInfoList } from "@/types/rentMachineManage/rentMachineOrderInfo";

/* 平台备注弹出框 */
function useSellerRemark(fn?: () => void) {
  const remarkVisible = ref(false);
  const sellerRemarkForm = ref<IDirectPurchaseOrderRemark>({
    id: 0,
    admin_note: ""
  });

  /* 平台备注 */
  function handleOrderRemark(row: IRentMachineOrderInfoList) {
    sellerRemarkForm.value.id = row.id;
    sellerRemarkForm.value.admin_note = row.admin_note;
    remarkVisible.value = true;
  }

  /* 平台备注成功回调 */
  function handleRemarkSuccess() {
    remarkVisible.value = false;
    if (fn) {
      fn();
    }
  }

  return {
    remarkVisible,
    sellerRemarkForm,
    handleOrderRemark,
    handleRemarkSuccess
  };
}

export default useSellerRemark;
